package bishi.Huawei;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

/**
 * @Classname IsVaild
 * @Description TODO
 * @Date 2021/9/11 10:09
 * @Created by ASUS
 */
public class IsVaild {

    static Map<Character, Character> map = new HashMap<>();

    public static String getData() {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        scanner.close();
        return s;
    }

    public static void main(String[] args) {
        map.put(')', '(');
        map.put(']', '[');
        map.put('}', '{');
        String data = getData();
        Stack<Character> stack = new Stack<>();
        // 循环遍历整个字符串
        for (char c : data.toCharArray()) {
            // 如果当前栈为空，直接push ()[]
            if (stack.isEmpty()) stack.push(c);
            else {// 栈不为空，和栈顶元素比较
                if (stack.peek() == map.get(c)) { // 如果栈顶元素和当前元素匹配，弹出栈顶元素，进行下一步操作
                    stack.pop();
                } else {
                    stack.push(c);
                }
            }
        }
        System.out.println(stack.isEmpty());
    }
}
